/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.DataAccess
*        文件名:             BaseResourcePermissionScopeDao.cs
*        创建系统时间:       2012/11/2 19:07:00
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.DataAccess
{
    using System.Data;
    using ECP.DataAccess.Utilities;
    using ECP.Model;
    using ECP.Utilities;

    public class BaseResourcePermissionScopeDao : BaseDao, IBaseDao
    {
        public static bool GetChildrensByCode = true;
        private static BaseResourcePermissionScopeDao instance = null;
        private static object locker = new object();

        public BaseResourcePermissionScopeDao()
        {
            base.CurrentTableName = BaseResourcePermissionScopeTable.TableName;
        }

        public BaseResourcePermissionScopeDao(IDbHelper dbHelper)
            : this()
        {
            base.DbHelper = dbHelper;
        }

        public BaseResourcePermissionScopeDao(IDbHelper dbHelper, BaseUserInfo userInfo)
            : this(dbHelper)
        {
            base.UserInfo = userInfo;
        }

        public string Add(BaseResourcePermissionScopeEntity resourcePermissionScope)
        {
            string str = string.Empty;
            if (!this.PermissionScopeExists(resourcePermissionScope.PermissionID, resourcePermissionScope.ResourceCategory, resourcePermissionScope.ResourceID, resourcePermissionScope.TargetCategory, resourcePermissionScope.TargetID))
            {
                str = this.AddEntity(resourcePermissionScope);
            }
            return str;
        }

        public string Add(string permissionID, string resourceCategory, string resourceID, string targetCategory, string targetID)
        {
            BaseResourcePermissionScopeEntity resourcePermissionScope = new BaseResourcePermissionScopeEntity
            {
                PermissionID = permissionID,
                ResourceCategory = resourceCategory,
                ResourceID = resourceID,
                TargetCategory = targetCategory,
                TargetID = targetID
            };
            return this.Add(resourcePermissionScope);
        }

        public string AddEntity(BaseResourcePermissionScopeEntity resourcePermissionScope)
        {
            string iD = resourcePermissionScope.ID;
            if (string.IsNullOrEmpty(iD))
            {
                iD = BaseSequenceDao.Instance.GetSequence(base.DbHelper, BaseResourcePermissionScopeTable.TableName);
            }
            SQLBuilder builder = new SQLBuilder(base.DbHelper);
            builder.BeginInsert(BaseResourcePermissionScopeTable.TableName);
            builder.SetValue(BaseResourcePermissionScopeTable.FieldID, iD);
            builder.SetValue(BaseResourcePermissionScopeTable.FieldPermissionID, resourcePermissionScope.PermissionID);
            builder.SetValue(BaseResourcePermissionScopeTable.FieldResourceCategory, resourcePermissionScope.ResourceCategory);
            builder.SetValue(BaseResourcePermissionScopeTable.FieldResourceID, resourcePermissionScope.ResourceID);
            builder.SetValue(BaseResourcePermissionScopeTable.FieldTargetCategory, resourcePermissionScope.TargetCategory);
            builder.SetValue(BaseResourcePermissionScopeTable.FieldTargetID, resourcePermissionScope.TargetID);
            builder.SetValue(BaseResourcePermissionScopeTable.FieldCreateUserID, base.UserInfo.ID);
            builder.SetDBNow(BaseResourcePermissionScopeTable.FieldCreateDate);
            return ((builder.EndInsert() > 0) ? iD : string.Empty);
        }

        private bool CheckResourcePermissionScope(IDbHelper dbHelper, string resourceCategory, string resourceID, string targetCategory, string targetID, string permissionID)
        {
            string sqlQuery = " SELECT COUNT(*)   FROM ECP_ResourcePermissionScope  WHERE (ECP_ResourcePermissionScope.ResourceCategory = '" + resourceCategory + "')       AND (ECP_ResourcePermissionScope.Enabled = 1)       AND (ECP_ResourcePermissionScope.ResourceID = '" + resourceID + "')       AND (ECP_ResourcePermissionScope.TargetCategory = '" + targetCategory + "')       AND (ECP_ResourcePermissionScope.TargetID = '" + targetID + "')       AND (ECP_ResourcePermissionScope.PermissionID = '" + permissionID + "'))";
            int num = 0;
            object obj2 = dbHelper.ExecuteScalar(sqlQuery);
            if (obj2 != null)
            {
                num = int.Parse(obj2.ToString());
            }
            return (num > 0);
        }

        private bool CheckRoleModulePermission(IDbHelper dbHelper, string userID, string moduleID, string permissionID)
        {
            return this.CheckRolePermissionScope(dbHelper, userID, "Module", moduleID, permissionID);
        }

        private bool CheckRolePermissionScope(IDbHelper dbHelper, string userID, string targetCategory, string targetID, string permissionID)
        {
            string sqlQuery = " SELECT COUNT(*)    FROM ECP_ResourcePermissionScope   WHERE (ECP_ResourcePermissionScope.ResourceCategory = 'Role')         AND (ECP_ResourcePermissionScope.Enabled = 1         AND (ECP_ResourcePermissionScope.ResourceID IN (  SELECT ECP_UserRole.RoleID    FROM ECP_UserRole   WHERE ECP_UserRole.UserID = '" + userID + "'        AND ECP_UserRole.Enabled = 1   UNION  SELECT " + BaseUserTable.FieldRole + "   FROM " + BaseUserTable.TableName + "  WHERE " + BaseUserTable.FieldID + " = '" + userID + "'))  AND (ECP_ResourcePermissionScope.TargetCategory = '" + targetCategory + "')  AND (ECP_ResourcePermissionScope.TargetID = '" + targetID + "')  AND (ECP_ResourcePermissionScope.PermissionID = '" + permissionID + "')) ";
            int num = 0;
            object obj2 = dbHelper.ExecuteScalar(sqlQuery);
            if (obj2 != null)
            {
                num = int.Parse(obj2.ToString());
            }
            return (num > 0);
        }

        private bool CheckUserModulePermission(IDbHelper dbHelper, string userID, string moduleID, string permissionID)
        {
            return this.CheckResourcePermissionScope(dbHelper, "User", userID, "Module", moduleID, permissionID);
        }

        public void ClearProperty(BaseResourcePermissionScopeEntity resourcePermissionScope)
        {
            resourcePermissionScope.ID = string.Empty;
            resourcePermissionScope.PermissionID = string.Empty;
            resourcePermissionScope.ResourceCategory = string.Empty;
            resourcePermissionScope.ResourceID = string.Empty;
            resourcePermissionScope.TargetCategory = string.Empty;
            resourcePermissionScope.TargetID = string.Empty;
            resourcePermissionScope.Enabled = true;
            resourcePermissionScope.Description = string.Empty;
            resourcePermissionScope.CreateUserID = string.Empty;
            resourcePermissionScope.CreateDate = string.Empty;
            resourcePermissionScope.ModifyUserID = string.Empty;
            resourcePermissionScope.ModifyDate = string.Empty;
        }

        public BaseResourcePermissionScopeEntity GetFrom(DataRow dataRow, BaseResourcePermissionScopeEntity resourcePermissionScope)
        {
            resourcePermissionScope.ID = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldID]);
            resourcePermissionScope.PermissionID = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldPermissionID]);
            resourcePermissionScope.ResourceCategory = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldResourceCategory]);
            resourcePermissionScope.ResourceID = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldResourceID]);
            resourcePermissionScope.TargetCategory = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldTargetCategory]);
            resourcePermissionScope.TargetID = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldTargetID]);
            resourcePermissionScope.Enabled = base.ConvertIntToBoolean(dataRow[BaseResourcePermissionScopeTable.FieldEnabled]);
            resourcePermissionScope.Description = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldDescription]);
            resourcePermissionScope.CreateUserID = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldCreateUserID]);
            resourcePermissionScope.CreateDate = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldCreateDate]);
            resourcePermissionScope.ModifyUserID = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldModifyUserID]);
            resourcePermissionScope.ModifyDate = base.ConvertToString(dataRow[BaseResourcePermissionScopeTable.FieldModifyDate]);
            return resourcePermissionScope;
        }

        public DataTable GetOrganizeDT(string managerUserID, string permissionCode)
        {
            string sqlQuery = string.Empty;
            if (BaseSystemInfo.GetChildrensByCode)
            {
                sqlQuery = this.GetOrganizeIDsSqlByCode(managerUserID, permissionCode);
            }
            else
            {
                sqlQuery = this.GetOrganizeIDsSqlByParentID(managerUserID, permissionCode);
            }
            sqlQuery = " SELECT * FROM " + BaseOrganizeTable.TableName + " WHERE " + BaseOrganizeTable.TableName + "." + BaseOrganizeTable.FieldID + " IN (" + sqlQuery + ")  ORDER BY " + BaseOrganizeTable.FieldSortCode;
            DataTable dataTable = new DataTable(BaseOrganizeTable.TableName);
            base.DbHelper.Fill(dataTable, sqlQuery);
            return dataTable;
        }

        public string[] GetOrganizeIDs(string managerUserID, string permissionCode)
        {
            string[] strArray = new string[0];
            string sqlQuery = string.Empty;
            if (BaseSystemInfo.GetChildrensByCode)
            {
                sqlQuery = this.GetOrganizeIDsSqlByCode(managerUserID, permissionCode);
            }
            else
            {
                sqlQuery = this.GetOrganizeIDsSqlByParentID(managerUserID, permissionCode);
            }
            DataTable dataTable = new DataTable(BaseOrganizeTable.TableName);
            base.DbHelper.Fill(dataTable, sqlQuery);
            return BaseBusinessLogic.FieldToArray(dataTable, BaseOrganizeTable.FieldID);
        }

        public string GetOrganizeIDsSql(string managerUserID, string permissionCode)
        {
            string iD = new BasePermissionAdminDao(base.DbHelper).GetID(permissionCode);
            return (" SELECT " + BaseResourcePermissionScopeTable.FieldTargetID + "   FROM " + BaseResourcePermissionScopeTable.TableName + "  WHERE (" + BaseResourcePermissionScopeTable.FieldTargetCategory + " = 'Organize')         AND ( " + BaseResourcePermissionScopeTable.TableName + "." + BaseResourcePermissionScopeTable.FieldEnabled + " = 1)         AND ( " + BaseResourcePermissionScopeTable.TableName + "." + BaseResourcePermissionScopeTable.FieldTargetID + " IS NOT NULL)         AND ((" + BaseResourcePermissionScopeTable.FieldResourceCategory + " = 'User'         AND " + BaseResourcePermissionScopeTable.FieldResourceID + " = '" + managerUserID + "') OR (" + BaseResourcePermissionScopeTable.FieldResourceCategory + " = 'Role'        AND " + BaseResourcePermissionScopeTable.FieldResourceID + " IN (  SELECT " + BaseUserRoleTable.FieldRoleID + "   FROM " + BaseUserRoleTable.TableName + "  WHERE " + BaseUserRoleTable.FieldUserID + " = '" + managerUserID + "'        AND " + BaseUserRoleTable.FieldEnabled + " = 1 ))  AND " + BaseResourcePermissionScopeTable.FieldPermissionID + " = '" + iD + "') ");
        }

        public string GetOrganizeIDsSqlByCode(string managerUserID, string permissionCode)
        {
            return (" SELECT " + BaseOrganizeTable.FieldID + " AS " + BaseBusinessLogic.FieldID + "   FROM " + BaseOrganizeTable.TableName + "         , ( SELECT " + base.DbHelper.PlusSign(new string[] { BaseOrganizeTable.FieldCode, "'%'" }) + " AS " + BaseOrganizeTable.FieldCode + "      FROM " + BaseOrganizeTable.TableName + "     WHERE " + BaseOrganizeTable.FieldID + " IN (" + this.GetOrganizeIDsSql(managerUserID, permissionCode) + ")) ManageOrganize  WHERE (" + BaseOrganizeTable.TableName + "." + BaseOrganizeTable.FieldEnabled + " = 1        AND " + BaseOrganizeTable.TableName + "." + BaseOrganizeTable.FieldCode + " LIKE ManageOrganize." + BaseOrganizeTable.FieldCode + ")");
        }

        public string GetOrganizeIDsSqlByParentID(string managerUserID, string permissionCode)
        {
            return (" SELECT ID    FROM " + BaseOrganizeTable.TableName + "  WHERE " + BaseOrganizeTable.TableName + "." + BaseOrganizeTable.FieldEnabled + " = 1   START WITH ID IN (" + this.GetOrganizeIDsSql(managerUserID, permissionCode) + ")  CONNECT BY PRIOR " + BaseOrganizeTable.FieldID + " = " + BaseOrganizeTable.FieldParentID);
        }

        public string[] GetResourceScopeIDs(string userID, string resourceCategory, string permissionCode)
        {
            string str = new BasePermissionAdminDao(base.DbHelper, base.UserInfo).FindID(BasePermissionTable.FieldCode, permissionCode);
            string property = new BaseUserDao(base.DbHelper, base.UserInfo).GetProperty(userID, BaseUserTable.FieldRole);
            string sqlQuery = string.Empty;
            sqlQuery = " SELECT ECP_ResourcePermissionScope.TargetID    FROM ECP_ResourcePermissionScope   WHERE (ECP_ResourcePermissionScope.ResourceCategory = 'User')         AND (ECP_ResourcePermissionScope.ResourceID = '" + userID + "')         AND (ECP_ResourcePermissionScope.TargetCategory = '" + resourceCategory + "')         AND (ECP_ResourcePermissionScope.PermissionID = '" + str + "')         AND (ECP_ResourcePermissionScope.Enabled = 1)  UNION  SELECT ECP_ResourcePermissionScope.TargetID    FROM ECP_ResourcePermissionScope   WHERE (ECP_ResourcePermissionScope.ResourceCategory  = 'Role')         AND (ECP_ResourcePermissionScope.TargetCategory  = '" + resourceCategory + "')         AND (ECP_ResourcePermissionScope.PermissionID = '" + str + "')         AND (ECP_ResourcePermissionScope.Enabled = 1)         AND ((ECP_ResourcePermissionScope.ResourceID IN (              SELECT ECP_UserRole.RoleID                FROM ECP_UserRole               WHERE (ECP_UserRole.UserID  = '" + userID + "')                   AND (ECP_UserRole.Enabled = 1))               OR (ECP_ResourcePermissionScope.ResourceID = '" + property + "'))) ";
            DataTable dataTable = new DataTable(BasePermissionTable.TableName);
            base.DbHelper.Fill(dataTable, sqlQuery);
            return BaseBusinessLogic.FieldToArray(dataTable, BaseResourcePermissionScopeTable.FieldTargetID);
        }

        public DataTable GetRoleDT(string managerUserID, string permissionCode)
        {
            string sqlQuery = string.Empty;
            string str2 = " SELECT * FROM " + BaseRoleTable.TableName;
            sqlQuery = str2 + " WHERE " + BaseRoleTable.TableName + "." + BaseRoleTable.FieldID + " IN (" + this.GetRoleIDsSql(managerUserID, permissionCode) + " )  ORDER BY " + BaseRoleTable.FieldSortCode;
            DataTable dataTable = new DataTable(BaseRoleTable.TableName);
            base.DbHelper.Fill(dataTable, sqlQuery);
            return dataTable;
        }

        public string[] GetRoleIDs(string managerUserID, string permissionCode)
        {
            string[] strArray = new string[0];
            string roleIDsSql = this.GetRoleIDsSql(managerUserID, permissionCode);
            DataTable dataTable = new DataTable(BaseRoleTable.TableName);
            base.DbHelper.Fill(dataTable, roleIDsSql);
            return BaseInterfaceLogic.GetIDs(dataTable, BaseBusinessLogic.FieldID);
        }

        public string GetRoleIDsSql(string managerUserID, string permissionCode)
        {
            string iD = new BasePermissionAdminDao(base.DbHelper).GetID(permissionCode);
            string str4 = string.Empty;
            string str2 = str4 + " SELECT ECP_ResourcePermissionScope.TargetID AS " + BaseBusinessLogic.FieldID + "   FROM ECP_ResourcePermissionScope   WHERE (ECP_ResourcePermissionScope.TargetID IS NOT NULL         AND ECP_ResourcePermissionScope.TargetCategory = 'Role'         AND ((ECP_ResourcePermissionScope.ResourceCategory = 'User'              AND ECP_ResourcePermissionScope.ResourceID = '" + managerUserID + "')        OR (ECP_ResourcePermissionScope.ResourceCategory = 'Role'            AND ECP_ResourcePermissionScope.ResourceID IN (  SELECT RoleID    FROM " + BaseUserRoleTable.TableName + "  WHERE (" + BaseUserRoleTable.FieldUserID + " = '" + managerUserID + "'         AND " + BaseUserRoleTable.FieldEnabled + " = 1))))        AND " + BaseResourcePermissionScopeTable.FieldPermissionID + " = '" + iD + "')";
            string[] organizeIDs = this.GetOrganizeIDs(managerUserID, permissionCode);
            if (organizeIDs.Length > 0)
            {
                string str3 = BaseBusinessLogic.ObjectsToList(organizeIDs);
                if (!string.IsNullOrEmpty(str3))
                {
                    string str5 = str2;
                    str2 = str5 + "  UNION  SELECT " + BaseRoleTable.TableName + "." + BaseRoleTable.FieldID + " AS " + BaseBusinessLogic.FieldID + "   FROM " + BaseRoleTable.TableName + "  WHERE " + BaseRoleTable.TableName + "." + BaseRoleTable.FieldOrganizeID + " IN (" + str3 + ") ";
                }
            }
            return str2;
        }

        public string[] GetTargetIDs(string userID, string targetCategory, string permissionID)
        {
            string[] strArray = new string[0];
            string[] names = new string[5];
            string[] values = new string[5];
            names[0] = BaseResourcePermissionScopeTable.FieldResourceCategory;
            values[0] = "User";
            names[1] = BaseResourcePermissionScopeTable.FieldResourceID;
            values[1] = userID;
            names[2] = BaseResourcePermissionScopeTable.FieldPermissionID;
            values[2] = permissionID;
            names[3] = BaseResourcePermissionScopeTable.FieldTargetCategory;
            values[3] = targetCategory;
            return BaseBusinessLogic.FieldToArray(this.GetDT(names, values), BaseResourcePermissionScopeTable.FieldTargetID);
        }

        public DataTable GetUserDT(string managerUserID, string permissionCode)
        {
            string sqlQuery = string.Empty;
            string str2 = " SELECT * FROM " + BaseUserTable.TableName;
            sqlQuery = str2 + " WHERE " + BaseUserTable.TableName + "." + BaseUserTable.FieldID + " IN (" + this.GetUserIDsSql(managerUserID, permissionCode) + " )  ORDER BY " + BaseUserTable.FieldSortCode;
            DataTable dataTable = new DataTable(BaseUserTable.TableName);
            base.DbHelper.Fill(dataTable, sqlQuery);
            return dataTable;
        }

        public string[] GetUserIDs(string managerUserID, string permissionCode)
        {
            string[] strArray = new string[0];
            string userIDsSql = this.GetUserIDsSql(managerUserID, permissionCode);
            DataTable dataTable = new DataTable(BaseUserTable.TableName);
            base.DbHelper.Fill(dataTable, userIDsSql);
            return BaseInterfaceLogic.GetIDs(dataTable, BaseBusinessLogic.FieldID);
        }

        public string GetUserIDsSql(string managerUserID, string permissionCode)
        {
            string iD = new BasePermissionAdminDao(base.DbHelper).GetID(permissionCode);
            string str2 = string.Empty;
            str2 = " SELECT ECP_ResourcePermissionScope.TargetID AS " + BaseBusinessLogic.FieldID + "   FROM ECP_ResourcePermissionScope   WHERE (ECP_ResourcePermissionScope.TargetCategory = 'User'        AND ECP_ResourcePermissionScope.ResourceID = '" + managerUserID + "'        AND ECP_ResourcePermissionScope.ResourceCategory = 'User'        AND ECP_ResourcePermissionScope.PermissionID = '" + iD + "'        AND ECP_ResourcePermissionScope.TargetID IS NOT NULL) ";
            string[] organizeIDs = this.GetOrganizeIDs(managerUserID, permissionCode);
            if (organizeIDs.Length > 0)
            {
                string str3 = BaseBusinessLogic.ObjectsToList(organizeIDs);
                if (!string.IsNullOrEmpty(str3))
                {
                    string str5 = str2;
                    str2 = str5 + " UNION  SELECT " + BaseStaffTable.TableName + "." + BaseStaffTable.FieldUserID + " AS " + BaseBusinessLogic.FieldID + "   FROM " + BaseStaffTable.TableName + "  WHERE (" + BaseStaffTable.TableName + "." + BaseStaffTable.FieldCompanyID + " IN (" + str3 + ")      OR " + BaseStaffTable.TableName + "." + BaseStaffTable.FieldDepartmentID + " IN (" + str3 + ")      OR " + BaseStaffTable.TableName + "." + BaseStaffTable.FieldWorkgroupID + " IN (" + str3 + ")) ";
                }
            }
            string[] roleIDs = this.GetRoleIDs(managerUserID, permissionCode);
            if (roleIDs.Length > 0)
            {
                string str4 = BaseBusinessLogic.ObjectsToList(roleIDs);
                if (!string.IsNullOrEmpty(str4))
                {
                    string str6 = str2;
                    str2 = str6 + " UNION  SELECT " + BaseUserRoleTable.TableName + "." + BaseUserRoleTable.FieldUserID + " AS " + BaseBusinessLogic.FieldID + "   FROM " + BaseUserRoleTable.TableName + "  WHERE (" + BaseUserRoleTable.TableName + "." + BaseUserRoleTable.FieldEnabled + " = 1         AND " + BaseUserRoleTable.TableName + "." + BaseUserRoleTable.FieldRoleID + " IN (" + str4 + ")) ";
                }
            }
            return str2;
        }

        public PermissionScope GetUserPermissionScope(string managerUserID, string permissionCode)
        {
            string organizeIDsSql = this.GetOrganizeIDsSql(managerUserID, permissionCode);
            DataTable dataTable = new DataTable(BaseOrganizeTable.TableName);
            base.DbHelper.Fill(dataTable, organizeIDsSql);
            return BaseBusinessLogic.GetPermissionScope(BaseBusinessLogic.FieldToArray(dataTable, BaseResourcePermissionScopeTable.FieldTargetID));
        }

        public bool ModuleIsAuthorized(IDbHelper dbHelper, BaseUserInfo userInfo, string moduleCode, string permissionCode)
        {
            return (userInfo.IsAdministrator || this.ModuleIsAuthorized(dbHelper, userInfo.ID, moduleCode, permissionCode));
        }

        public bool ModuleIsAuthorized(IDbHelper dbHelper, string userID, string moduleCode, string permissionCode)
        {
            string code = new BaseModuleDao(dbHelper).GetCode(moduleCode);
            string permissionID = new BasePermissionAdminDao(dbHelper).GetCode(permissionCode);
            return (this.CheckUserModulePermission(dbHelper, userID, code, permissionID) || this.CheckRoleModulePermission(dbHelper, userID, code, permissionID));
        }

        public int PermissionScopeDelete(string permissionID, string resourceCategory, string resourceID, string targetCategory, string targetID)
        {
            string[] names = new string[5];
            string[] strArray2 = new string[5];
            names[0] = BaseResourcePermissionScopeTable.FieldPermissionID;
            strArray2[0] = permissionID;
            names[1] = BaseResourcePermissionScopeTable.FieldResourceCategory;
            strArray2[1] = resourceCategory;
            names[2] = BaseResourcePermissionScopeTable.FieldResourceID;
            strArray2[2] = resourceID;
            names[3] = BaseResourcePermissionScopeTable.FieldTargetCategory;
            strArray2[3] = targetCategory;
            names[4] = BaseResourcePermissionScopeTable.FieldTargetID;
            strArray2[4] = targetID;
            return this.BatchDelete(names, (object[])strArray2);
        }

        public bool PermissionScopeExists(string permissionID, string resourceCategory, string resourceID, string targetCategory, string targetID)
        {
            bool flag = true;
            string[] names = new string[5];
            string[] values = new string[5];
            names[0] = BaseResourcePermissionScopeTable.FieldPermissionID;
            values[0] = permissionID;
            names[1] = BaseResourcePermissionScopeTable.FieldResourceCategory;
            values[1] = resourceCategory;
            names[2] = BaseResourcePermissionScopeTable.FieldResourceID;
            values[2] = resourceID;
            names[3] = BaseResourcePermissionScopeTable.FieldTargetCategory;
            values[3] = targetCategory;
            names[4] = BaseResourcePermissionScopeTable.FieldTargetID;
            values[4] = targetID;
            if (!this.Exists(names, values))
            {
                flag = false;
            }
            return flag;
        }

        public static BaseResourcePermissionScopeDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (locker)
                    {
                        if (instance == null)
                        {
                            instance = new BaseResourcePermissionScopeDao();
                        }
                    }
                }
                return instance;
            }
        }
    }
}